<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.form.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.livequery.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.validate.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery.validate.extend.js"></script>


<div class="module">
   <p class="title">用户信息</p>
   
   <form id="form" enctype="multipart/form-data" method=”post”>
   		<div class="content">
       	   <br>
           <ul class="summary-table" style="width: 95%;margin: auto auto">
               
               <li>
                   <label class="col1">帐号</label>
                   <span class="col2">
                       <input class="ctr-input" id="userName" name="userName" data-vdt="required" value="${sessionScope.loginInfo.userName }" readonly="readonly"/>
                   </span>
               </li>
               
               <li>
                   <label class="col1">用户类型 </label>
                   <span class="col2">
                   		<c:set var="managerGrade" />
                   		<c:if test="${sessionScope.loginInfo.managerGrade=='0' }"><c:set var="managerGrade" value="总管理员" /></c:if>
                   		<c:if test="${sessionScope.loginInfo.managerGrade==1 }"><c:set var="managerGrade" value="车场总管理员" /></c:if>
                   		<c:if test="${sessionScope.loginInfo.managerGrade==2 }"><c:set var="managerGrade" value="操作员" /></c:if>
						                   
                        <input class="ctr-input" id="managerGrade" name="managerGrade" value="${managerGrade }" readonly="readonly"/>
                   </span>
               </li>

			   <li>
                   <label class="col1">手机号</label>
                   <span class="col2">
                       <input class="ctr-input" id="mobile" name="mobile" data-vdt="required" value="${sessionScope.loginInfo.mobile }" readonly="readonly"/>
                   </span>
               </li>
            
               <li>
                   <label class="col1">上级管理员</label>
                   <span class="col2">
                       <input class="ctr-input" id="mobile" name="mobile" data-vdt="required" value="${null==upManager?'-':upManager.userName }" readonly="readonly"/>
                   </span>
               </li>
               
               <li>
                   <label class="col1">注册时间</label>
                   <span class="col2">
                       <input class="Wdate ctr-input" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="birthdays" id="birthday" value="<fmt:formatDate value="${sessionScope.loginInfo.createTime }" pattern="yyyy-MM-dd"/>" readonly="readonly"/></span></li>
                   </span>
               </li>
               
               <li>
                   <label class="col1">&nbsp;</label>
                   <span class="col2">
                   		<a href="/web/parkingCenter/index">我的车场</a>
                   </span>
               </li>
			
               
               <li>
                   <label class="col1"></label>
                   <input name='userid' value="${user.userid  }" style="display: none;">
               </li>
               
           </ul>
		   
		   <!-- 
           <div class="form-button-group" style="margin: auto auto">
               <span class="form-button editBtn" id="loginInfoSubmit">编辑</span>
               <span class="form-button cancelBtn" id="cancelBtn" onclick="javascript: getLoginInfo();" style="display: none;">取消</span>
           </div>
            -->
        
    	</div>
    </form>
</div>
<script type="text/javascript">
	$('#loginInfoSubmit').bind('click', function(){
		
		changeBtn(this);
		
	});
	
	
	function changeBtn(obj){
		if('编辑'==$(obj).text()){
			$('#form input').removeAttr('readonly');
			$('#form select').removeAttr('disabled');
			
			$(obj).removeClass('editBtn').addClass('saveBtn').text('保存');
			$('#cancelBtn').show();
			
			
			/****************************/
			$("#account").attr('disabled', 'disabled');
			$("#usertypeName").attr('disabled', 'disabled');
			$("#islogin").attr('disabled', 'disabled');
			$("#logintime").attr('disabled', 'disabled');
			$("#days").attr('disabled', 'disabled');
			$("#worknum").attr('disabled', 'disabled');
			$("#socre").attr('disabled', 'disabled');
			$("#regtime").attr('disabled', 'disabled');
			$("#_isvalidity").attr('disabled', 'disabled');
			
		}
		else{
			
			updateUserInfo();
			
		}
	}
	
	
	
	function updateUserInfo(){
		if($("#form").valid()){
			var options = {
		                url: contextPath + "/view/settings/updateUserInfo",
		                type: 'post',
		                dataType: 'json',
		                data: $("#form").serialize(),
		                beforeSend : function(){
			            	$("#beforeLoading").show();
			            },
		                success: function (res) {
		                	$("#beforeLoading").hide();
			            	if(res.status){
			            		
			            		succHint();
			            		
			            		setTimeout(function(){
			            			getLoginInfo();
		                		}, 2500);
			            		
			            	}
			            	else{
			            		failHint(res.msg);
			            	}
			            },
			            error: function (msg) {
			            	failHint();
			            }
		        	};
			$("#form").ajaxSubmit(options);
          	return false;
		}
	}
	
	/**
	function updateUserInfo(){
		if($("#form").valid()){
			$.ajax({
	            type: "POST",
	            url: contextPath + "/view/settings/updateUserInfo",
	            data: $("#form").serialize(),
	            dataType : "json",
	            beforeSend : function(){
	            	$("#beforeLoading").show();
	            },
	            success: function (res) {
	            	$("#beforeLoading").hide();
	            	if(res.status){
	            		
	            		succHint();
	            		
	            		setTimeout(function(){
	            			getLoginInfo();
                		}, 2500);
	            		
	            	}
	            	else{
	            		failHint(res.msg);
	            	}
	            	
	            },
	            error: function (msg) {
	            	failHint();
	            }
	        });
		}
	}
	**/
</script>
